﻿using System;
using log4net;

namespace ASPItalia.ModelVirtualCasting
{
    public static class ExceptionLogWriter
    {
        private readonly static ILog _logger = LogManager.GetLogger("ExceptionLog");

        public static ILog ExceptionLogger
        {
            get { return _logger; }
        } 

        public static bool ExceptionLogEnabled
        {
            get { return Configuration.ExceptionLogEnabled; }
        }

        public static void Write(string methodName, Exception exception)
        {
            try
            {
                if ((methodName.IsNotNull()) && (ExceptionLogWriter.ExceptionLogEnabled))
                {
                    ExceptionLogger.Error("Method: " + methodName, exception);
                }
            }
            catch (Exception)
            {
                // Do nothing!
            }
        }
    }
}
